package com.wsd.dao;

import com.wsd.domain.LoanInfo;
import com.wsd.domain.LoanInformation;
import com.wsd.domain.NormalLoan;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

@Repository
public interface LoanInformationMapper {
    int deleteByPrimaryKey(Long loanId);

    int insert(LoanInformation record);

    int insertSelective(LoanInformation record);

    LoanInformation selectByPrimaryKey(Long loanId);

    int updateByPrimaryKeySelective(LoanInformation record);

    int updateByPrimaryKey(LoanInformation record);

    /**
     * 根据客户编号查找贷款信息
     *
     * @param customerId
     * @return
     */
    List<LoanInformation> selectLoanByCustomerId(@Param("customerId") long customerId);

    BigDecimal sumLoanMoney(List<Long> list);//计算贷款编号在list中的贷款的总额

    BigDecimal sumRemainPrincipal(List<Long> list);//计算贷款编号在list中的贷款的已还本金总额

    NormalLoan findFormInfoById(Long loanId);

    List<LoanInfo> findEndLoanList(int start,int num);

    List<LoanInfo> findIngLoanList(int start,int num);

    Long countEndLoanList();

    Long countIngLoanList();


    /**
     * 按状态返回所有贷款列表
     * @param status
     * 0申请中 1进行中 2已完结
     * @return
     * 贷款信息列表
     * by WangYuCan
     */
    List<LoanInformation> findLoanListByStatus(String status);

    /**
     *批量更新贷款状态
     * @param loanInformations
     * 贷款信息列表
     * @return
     * 更新的记录条数
     * by WangYuCan
     */
    int updateLoanStatus(List<LoanInformation> loanInformations);

    /**
     * 根据用户ID查找用户所有贷款ID列表
     * @param customerId 用户ID
     * @return 贷款ID列表
     * by WangYuCan
     */
    List<Long> selectLoanIdByCustomerId(long customerId);
}